import { reactive } from "vue";

const Chart = reactive({
  curNow: 0,
  tablist: [
    {
      title: "日",
      value: 1,
    },
    {
      title: "月",
      value: 2,
    },
    {
      title: "年",
      value: 3,
    },
  ],
  chartData: {},
  ops: {
    legend: {
      show: false,
      position: "bottom",
      lineHeight: 25,
    },
    color: ["#3092ff" /*  "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc" */],
    padding: [15, 15, 15, 15],
    enableScroll: true,
    enableMarkLine: true,
    xAxis: {
      disableGrid: true,
      itemCount: 10,
      // labelCount: 1,
    },
    yAxis: {
      data: [],
    },
    extra: {
      area: {
        opacity: 1,
        addLine: true,
        gradient: true,
        activeType: "solid",
      },
    },
  },
});

const getChartData = (data: any) => {
  //模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
  let res = {
    categories: ["2018", "2019", "2020", "2021", "2022", "2023", "2021", "2022", "2023"],
    series: [
      {
        name: "成交量A",
        data: [35, 8, 25, 37, 4, 20, 25, 37, 4],
      },
    ],
  };
  Chart.chartData = JSON.parse(JSON.stringify(res));
};

export default {
  Chart,
  getChartData,
};
